package com.qzw.study.circledepend;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import java.time.Period;

/**
 * @author quziwei
 * @date 2020/10/04
 * @description
 **/
@Configuration
public class SelfInstantiationAwareBeanPostProcessor implements InstantiationAwareBeanPostProcessor {
	@Override
	public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException {
		if (beanClass == Person.class) {
			Person person = new Person();
			person.setName("create by beanFactoryPostProcessor");
			return person;
		}
		return null;
	}
}
